New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

string-random

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

string-random

Generate random string

  • 0.1.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
31K
increased by3.93%
Maintainers
1
Weekly downloads
 
Created
Source

#string-random

Generate random string

Installation

string-random is available as an npm package.

npm i string-random

Document

random([length],[options])

length

{number} the length of the result, default 8

options

{boolean|object} default {}, true=={specials: true}

options.numbers

{boolean|string} should contain numbers, default true, if is string, only contain assigned numbers.

options.letters

{boolean|string} should contain letters, default true, if is string, only contain assigned letters.

options.specials

{boolean|string} should contain specials, default false, if is string, only contain assigned specials.

Example


const random = require('string-random');
//import random from 'string-random';

console.log(random());        //jcBvYzfa
console.log(random(16));      //d9oq0A3vooaDod8X
console.log(random(16, {numbers: false}));     //AgfPTKheCgMvwNqX
console.log(random(16, {letters: false}));     //0889014544916637
console.log(random(16, {letters: 'ABCDEFG'})); //055B1627E43GA7D8
console.log(random(16, {specials: true}));     //,o=8l{iay>AOegW[
console.log(random(16, {specials: true, numbers: false, letters: false}));    //)-[+$^%+$|)-{(]%
console.log(random(16, {specials: ':;', numbers: false, letters: false}));    //:;:;;;:;;;;;;;::
console.log(random(16, true)); //SMm,EjETKMldIM/J

Contribute

Maichong Software

Liang Xingchen

License

This project is licensed under the terms of the MIT license

FAQs

Package last updated on 19 Nov 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc